<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Hello World!</h1>
用户名: <input id="txt1" type="text" name="fname" />
密码: <input  id="txt2" type="text" name="lname" />
<button type="button" onclick="myFunction()">提交</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x,y,a,b;
    x = document.getElementById("txt1").value;
    a = "用户名：";
    y = document.getElementById("txt2").value;
    b = "      密码：";
    document.getElementById("demo").innerHTML = a+x+b+y;
}
</script>
</body>
</html>
